load("02_18_m5s_forum_text_wt_aggres.RData")

# Find issues: 
# Issue classification is boolean
issue_df <- data.frame(
  issue = c("immigration", "gmi", "euro", "unemployment", "elections", 
              "mafia", "water", "housing", "taxes", "grillo", "casaleggio", "fiducia"),
  regex = c("immigr", "reddito (di cittadinanza|minimo)", "\\bdall(.)euro\\b", "disoccupa", "elezion", 
             "\\bmafi|\\bcamorr|ndrangh", "\\bacqua\\b", "\\bcasa\\b", "\\btass", "\\bgrillo\\b", "\\bcasaleggio\\b", "(?=.*(vot(.*?)|dare|diamo)\\s(di|la)\\s(fiducia))(?=.*bersani)"),
  stringsAsFactors = FALSE
)

require(plyr)
for (i in 1:nrow(issue_df)) {
  print(issue_df$issue[i])
  forum_text$newCol <-
    grepl(issue_df$regex[i], forum_text$text, ignore.case = TRUE, perl=TRUE)
  forum_text <-
    rename(forum_text, c("newCol"=issue_df$issue[i]))
}

save(forum_text, file = "02_19_m5s_forum_text_wt_issues.RData")
